home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / dix / swapreq.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-06  |  25.2 KB  |  1,123 lines

  1. /************************************************************
  2. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  3. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its 
  8. documentation for any purpose and without fee is hereby granted, 
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in 
  11. supporting documentation, and that the names of Digital or MIT not be
  12. used in advertising or publicity pertaining to distribution of the
  13. software without specific, written prior permission.  
  14.  
  15. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  16. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  17. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  18. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  19. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  20. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21. SOFTWARE.
  22.  
  23. ********************************************************/
  24.  
  25. /* $XConsortium: swapreq.c,v 1.29 89/07/03 19:50:28 rws Exp $ */
  26. /* $Header: /X11/R4/src/cmds/X/dix/RCS/swapreq.c,v 1.2 91/02/05 17:32:05 kupfer Exp $ */
  27.  
  28. #include "X.h"
  29. #define NEED_EVENTS
  30. #include "Xproto.h"
  31. #include "Xprotostr.h"
  32. #include "misc.h"
  33. #include "dixstruct.h"
  34.  
  35. extern int (* ProcVector[256]) ();
  36. extern void (* EventSwapVector[128]) ();  /* for SendEvent */
  37.  
  38. /* Thanks to Jack Palevich for testing and subsequently rewriting all this */
  39.  
  40. /* Byte swap a list of longs */
  41.  
  42. void
  43. SwapLongs (list, count)
  44.     register long *list;
  45.     register unsigned long count;
  46. {
  47.     register int n;
  48.  
  49.     while (count >= 8) {
  50.         swapl(list+0, n);
  51.         swapl(list+1, n);
  52.         swapl(list+2, n);
  53.         swapl(list+3, n);
  54.         swapl(list+4, n);
  55.         swapl(list+5, n);
  56.         swapl(list+6, n);
  57.         swapl(list+7, n);
  58.         list += 8;
  59.         count -= 8;
  60.     }
  61.     if (count != 0) {
  62.         do {
  63.         swapl(list, n);
  64.         list++;
  65.         } while (--count != 0);
  66.     }
  67. }
  68.  
  69. /* Byte swap a list of shorts */
  70.  
  71. void
  72. SwapShorts (list, count)
  73.     register short *list;
  74.     register unsigned long count;
  75. {
  76.     register int n;
  77.  
  78.     while (count >= 16) {
  79.         swaps(list+0, n);
  80.         swaps(list+1, n);
  81.         swaps(list+2, n);
  82.         swaps(list+3, n);
  83.         swaps(list+4, n);
  84.         swaps(list+5, n);
  85.         swaps(list+6, n);
  86.         swaps(list+7, n);
  87.         swaps(list+8, n);
  88.         swaps(list+9, n);
  89.         swaps(list+10, n);
  90.         swaps(list+11, n);
  91.         swaps(list+12, n);
  92.         swaps(list+13, n);
  93.         swaps(list+14, n);
  94.         swaps(list+15, n);
  95.         list += 16;
  96.         count -= 16;
  97.     }
  98.     if (count != 0) {
  99.         do {
  100.         swaps(list, n);
  101.         list++;
  102.         } while (--count != 0);
  103.     }
  104. }
  105.  
  106. /* The following is used for all requests that have
  107.    no fields to be swapped (except "length") */
  108. int
  109. SProcSimpleReq(client)
  110.     register ClientPtr client;
  111. {
  112.     register char n;
  113.  
  114.     REQUEST(xReq);
  115.     swaps(&stuff->length, n);
  116.     return(*ProcVector[stuff->reqType])(client);
  117. }
  118.  
  119. /* The following is used for all requests that have
  120.    only a single 32-bit field to be swapped, coming
  121.    right after the "length" field */
  122. int
  123. SProcResourceReq(client)
  124.     register ClientPtr client;
  125. {
  126.     register char n;
  127.  
  128.     REQUEST(xResourceReq);
  129.     swaps(&stuff->length, n);
  130.     swapl(&stuff->id, n);
  131.     return(*ProcVector[stuff->reqType])(client);
  132. }
  133.  
  134. int
  135. SProcCreateWindow(client)
  136.     register ClientPtr client;
  137. {
  138.     register char n;
  139.  
  140.     REQUEST(xCreateWindowReq);
  141.     swaps(&stuff->length, n);
  142.     REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
  143.     swapl(&stuff->wid, n);
  144.     swapl(&stuff->parent, n);
  145.     swaps(&stuff->x, n);
  146.     swaps(&stuff->y, n);
  147.     swaps(&stuff->width, n);
  148.     swaps(&stuff->height, n);
  149.     swaps(&stuff->borderWidth, n);
  150.     swaps(&stuff->class, n);
  151.     swapl(&stuff->visual, n);
  152.     swapl(&stuff->mask, n);
  153.     SwapRestL(stuff);
  154.     return((* ProcVector[X_CreateWindow])(client));
  155. }
  156.  
  157. int
  158. SProcChangeWindowAttributes(client)
  159.     register ClientPtr client;
  160. {
  161.     register char n;
  162.  
  163.     REQUEST(xChangeWindowAttributesReq);
  164.     swaps(&stuff->length, n);
  165.     REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
  166.     swapl(&stuff->window, n);
  167.     swapl(&stuff->valueMask, n);
  168.     SwapRestL(stuff);
  169.     return((* ProcVector[X_ChangeWindowAttributes])(client));
  170. }
  171.  
  172. int
  173. SProcReparentWindow(client)
  174.     register ClientPtr client;
  175. {
  176.     register char n;
  177.     REQUEST(xReparentWindowReq);
  178.     swaps(&stuff->length, n);
  179.     swapl(&stuff->window, n);
  180.     swapl(&stuff->parent, n);
  181.     swaps(&stuff->x, n);
  182.     swaps(&stuff->y, n);
  183.     return((* ProcVector[X_ReparentWindow])(client));
  184. }
  185.  
  186. int
  187. SProcConfigureWindow(client)
  188.     register ClientPtr client;
  189. {
  190.     register char n;
  191.     REQUEST(xConfigureWindowReq);
  192.     swaps(&stuff->length, n);
  193.     REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
  194.     swapl(&stuff->window, n);
  195.     swaps(&stuff->mask, n);
  196.     SwapRestL(stuff);
  197.     return((* ProcVector[X_ConfigureWindow])(client));
  198.  
  199. }
  200.  
  201.  
  202. int
  203. SProcInternAtom(client)
  204.     register ClientPtr client;
  205. {
  206.     register char n;
  207.     REQUEST(xInternAtomReq);
  208.     swaps(&stuff->length, n);
  209.     swaps(&stuff->nbytes, n);
  210.     return((* ProcVector[X_InternAtom])(client));
  211. }
  212.  
  213. int
  214. SProcChangeProperty(client)
  215.     register ClientPtr client;
  216. {
  217.     register char n;
  218.     REQUEST(xChangePropertyReq);
  219.     swaps(&stuff->length, n);
  220.     swapl(&stuff->window, n);
  221.     swapl(&stuff->property, n);
  222.     swapl(&stuff->type, n);
  223.     swapl(&stuff->nUnits, n);
  224.     switch ( stuff->format ) {
  225.         case 8 : break;
  226.         case 16:
  227.             SwapShorts((short *)(stuff + 1), stuff->nUnits);
  228.         break;
  229.     case 32:
  230.         SwapLongs((long *)(stuff + 1), stuff->nUnits);
  231.         break;
  232.     }
  233.     return((* ProcVector[X_ChangeProperty])(client));
  234. }
  235.  
  236. int 
  237. SProcDeleteProperty(client)
  238.     register ClientPtr client;
  239. {
  240.     register char n;
  241.     REQUEST(xDeletePropertyReq);
  242.     swaps(&stuff->length, n);
  243.     swapl(&stuff->window, n);
  244.     swapl(&stuff->property, n);
  245.     return((* ProcVector[X_DeleteProperty])(client));
  246.               
  247. }
  248.  
  249. int 
  250. SProcGetProperty(client)
  251.     register ClientPtr client;
  252. {
  253.     register char n;
  254.     REQUEST(xGetPropertyReq);
  255.     swaps(&stuff->length, n);
  256.     swapl(&stuff->window, n);
  257.     swapl(&stuff->property, n);
  258.     swapl(&stuff->type, n);
  259.     swapl(&stuff->longOffset, n);
  260.     swapl(&stuff->longLength, n);
  261.     return((* ProcVector[X_GetProperty])(client));
  262. }
  263.  
  264. int
  265. SProcSetSelectionOwner(client)
  266.     register ClientPtr client;
  267. {
  268.     register char n;
  269.     REQUEST(xSetSelectionOwnerReq);
  270.     swaps(&stuff->length, n);
  271.     swapl(&stuff->window, n);
  272.     swapl(&stuff->selection, n);
  273.     swapl(&stuff->time, n);
  274.     return((* ProcVector[X_SetSelectionOwner])(client));
  275. }
  276.  
  277. int
  278. SProcConvertSelection(client)
  279.     register ClientPtr client;
  280. {
  281.     register char n;
  282.     REQUEST(xConvertSelectionReq);
  283.     swaps(&stuff->length, n);
  284.     swapl(&stuff->requestor, n);
  285.     swapl(&stuff->selection, n);
  286.     swapl(&stuff->target, n);
  287.     swapl(&stuff->property, n);
  288.     swapl(&stuff->time, n);
  289.     return((* ProcVector[X_ConvertSelection])(client));
  290. }
  291.  
  292. int
  293. SProcSendEvent(client)
  294.     register ClientPtr client;
  295. {
  296.     register char n;
  297.     xEvent eventT;
  298.     void (*proc)();
  299.     REQUEST(xSendEventReq);
  300.     swaps(&stuff->length, n);
  301.     swapl(&stuff->destination, n);
  302.     swapl(&stuff->eventMask, n);
  303.  
  304.     /* Swap event */
  305.     proc = EventSwapVector[stuff->event.u.u.type & 0177];
  306.     if (!proc)   /* no swapping proc; invalid event type? */
  307.        return (BadValue);
  308.     (*proc)(&stuff->event, &eventT);
  309.     stuff->event = eventT;
  310.  
  311.     return((* ProcVector[X_SendEvent])(client));
  312. }
  313.  
  314. int
  315. SProcGrabPointer(client)
  316.     register ClientPtr client;
  317. {
  318.     register char n;
  319.     REQUEST(xGrabPointerReq);
  320.     swaps(&stuff->length, n);
  321.     swapl(&stuff->grabWindow, n);
  322.     swaps(&stuff->eventMask, n);
  323.     swapl(&stuff->confineTo, n);
  324.     swapl(&stuff->cursor, n);
  325.     swapl(&stuff->time, n);
  326.     return((* ProcVector[X_GrabPointer])(client));
  327. }
  328.  
  329. int
  330. SProcGrabButton(client)
  331.     register ClientPtr client;
  332. {
  333.     register char n;
  334.     REQUEST(xGrabButtonReq);
  335.     swaps(&stuff->length, n);
  336.     swapl(&stuff->grabWindow, n);
  337.     swaps(&stuff->eventMask, n);
  338.     swapl(&stuff->confineTo, n);
  339.     swapl(&stuff->cursor, n);
  340.     swaps(&stuff->modifiers, n);
  341.     return((* ProcVector[X_GrabButton])(client));
  342. }
  343.  
  344. int
  345. SProcUngrabButton(client)
  346.     register ClientPtr client;
  347. {
  348.     register char n;
  349.     REQUEST(xUngrabButtonReq);
  350.     swaps(&stuff->length, n);
  351.     swapl(&stuff->grabWindow, n);
  352.     swaps(&stuff->modifiers, n);
  353.     return((* ProcVector[X_UngrabButton])(client));
  354. }
  355.  
  356. int
  357. SProcChangeActivePointerGrab(client)
  358.     register ClientPtr client;
  359. {
  360.     register char n;
  361.     REQUEST(xChangeActivePointerGrabReq);
  362.     swaps(&stuff->length, n);
  363.     swapl(&stuff->cursor, n);
  364.     swapl(&stuff->time, n);
  365.     swaps(&stuff->eventMask, n);
  366.     return((* ProcVector[X_ChangeActivePointerGrab])(client));
  367. }
  368.  
  369. int
  370. SProcGrabKeyboard(client)
  371.     register ClientPtr client;
  372. {
  373.     register char n;
  374.     REQUEST(xGrabKeyboardReq);
  375.     swaps(&stuff->length, n);
  376.     swapl(&stuff->grabWindow, n);
  377.     swapl(&stuff->time, n);
  378.     return((* ProcVector[X_GrabKeyboard])(client));
  379. }
  380.  
  381. int
  382. SProcGrabKey(client)
  383.     register ClientPtr client;
  384. {
  385.     register char n;
  386.     REQUEST(xGrabKeyReq);
  387.     swaps(&stuff->length, n);
  388.     swapl(&stuff->grabWindow, n);
  389.     swaps(&stuff->modifiers, n);
  390.     return((* ProcVector[X_GrabKey])(client));
  391. }
  392.  
  393. int
  394. SProcUngrabKey(client)
  395.     register ClientPtr client;
  396. {
  397.     register char n;
  398.     REQUEST(xUngrabKeyReq);
  399.     swaps(&stuff->length, n);
  400.     swapl(&stuff->grabWindow, n);
  401.     swaps(&stuff->modifiers, n);
  402.     return((* ProcVector[X_UngrabKey])(client));
  403. }
  404.  
  405. int
  406. SProcGetMotionEvents(client)
  407.     register ClientPtr client;
  408. {
  409.     register char n;
  410.     REQUEST(xGetMotionEventsReq);
  411.     swaps(&stuff->length, n);
  412.     swapl(&stuff->window, n);
  413.     swapl(&stuff->start, n);
  414.     swapl(&stuff->stop, n);
  415.     return((* ProcVector[X_GetMotionEvents])(client));
  416. }
  417.  
  418. int
  419. SProcTranslateCoords(client)
  420.     register ClientPtr client;
  421. {
  422.     register char n;
  423.     REQUEST(xTranslateCoordsReq);
  424.     swaps(&stuff->length, n);
  425.     swapl(&stuff->srcWid, n);
  426.     swapl(&stuff->dstWid, n);
  427.     swaps(&stuff->srcX, n);
  428.     swaps(&stuff->srcY, n);
  429.     return((* ProcVector[X_TranslateCoords])(client));
  430. }
  431.  
  432. int
  433. SProcWarpPointer(client)
  434.     register ClientPtr client;
  435. {
  436.     register char n;
  437.     REQUEST(xWarpPointerReq);
  438.     swaps(&stuff->length, n);
  439.     swapl(&stuff->srcWid, n);
  440.     swapl(&stuff->dstWid, n);
  441.     swaps(&stuff->srcX, n);
  442.     swaps(&stuff->srcY, n);
  443.     swaps(&stuff->srcWidth, n);
  444.     swaps(&stuff->srcHeight, n);
  445.     swaps(&stuff->dstX, n);
  446.     swaps(&stuff->dstY, n);
  447.     return((* ProcVector[X_WarpPointer])(client));
  448. }
  449.  
  450. int
  451. SProcSetInputFocus(client)
  452.     register ClientPtr client;
  453. {
  454.     register char n;
  455.     REQUEST(xSetInputFocusReq);
  456.     swaps(&stuff->length, n);
  457.     swapl(&stuff->focus, n);
  458.     swapl(&stuff->time, n);
  459.     return((* ProcVector[X_SetInputFocus])(client));
  460. }
  461.  
  462.  
  463. SProcOpenFont(client)
  464.     register ClientPtr client;
  465. {
  466.     register char n;
  467.     REQUEST(xOpenFontReq);
  468.     swaps(&stuff->length, n);
  469.     swapl(&stuff->fid, n);
  470.     swaps(&stuff->nbytes, n);
  471.     return((* ProcVector[X_OpenFont])(client));
  472. }
  473.  
  474. int
  475. SProcListFonts(client)
  476.     register ClientPtr client;
  477. {
  478.     register char n;
  479.     REQUEST(xListFontsReq);
  480.     swaps(&stuff->length, n);
  481.     swaps(&stuff->maxNames, n);
  482.     swaps(&stuff->nbytes, n);
  483.     return((* ProcVector[X_ListFonts])(client));
  484. }
  485.  
  486. int
  487. SProcListFontsWithInfo(client)
  488.     register ClientPtr client;
  489. {
  490.     register char n;
  491.     REQUEST(xListFontsWithInfoReq);
  492.     swaps(&stuff->length, n);
  493.     swaps(&stuff->maxNames, n);
  494.     swaps(&stuff->nbytes, n);
  495.     return((* ProcVector[X_ListFontsWithInfo])(client));
  496. }
  497.  
  498. int
  499. SProcSetFontPath(client)
  500.     register ClientPtr client;
  501. {
  502.     register char n;
  503.     REQUEST(xSetFontPathReq);
  504.     swaps(&stuff->length, n);
  505.     swaps(&stuff->nFonts, n);
  506.     return((* ProcVector[X_SetFontPath])(client));
  507. }
  508.  
  509. int
  510. SProcCreatePixmap(client)
  511.     register ClientPtr client;
  512. {
  513.     register char n;
  514.     REQUEST(xCreatePixmapReq);
  515.  
  516.     swaps(&stuff->length, n);
  517.     swapl(&stuff->pid, n);
  518.     swapl(&stuff->drawable, n);
  519.     swaps(&stuff->width, n);
  520.     swaps(&stuff->height, n);
  521.     return((* ProcVector[X_CreatePixmap])(client));
  522. }
  523.  
  524. int
  525. SProcCreateGC(client)
  526.     register ClientPtr client;
  527. {
  528.     register char n;
  529.     REQUEST(xCreateGCReq);
  530.     swaps(&stuff->length, n);
  531.     REQUEST_AT_LEAST_SIZE(xCreateGCReq);
  532.     swapl(&stuff->gc, n);
  533.     swapl(&stuff->drawable, n);
  534.     swapl(&stuff->mask, n);
  535.     SwapRestL(stuff);
  536.     return((* ProcVector[X_CreateGC])(client));
  537. }
  538.  
  539. int
  540. SProcChangeGC(client)
  541.     register ClientPtr client;
  542. {
  543.     register char n;
  544.     REQUEST(xChangeGCReq);
  545.     swaps(&stuff->length, n);
  546.     REQUEST_AT_LEAST_SIZE(xChangeGCReq);
  547.     swapl(&stuff->gc, n);
  548.     swapl(&stuff->mask, n);
  549.     SwapRestL(stuff);
  550.     return((* ProcVector[X_ChangeGC])(client));
  551. }
  552.  
  553. int
  554. SProcCopyGC(client)
  555.     register ClientPtr client;
  556. {
  557.     register char n;
  558.     REQUEST(xCopyGCReq);
  559.     swaps(&stuff->length, n);
  560.     swapl(&stuff->srcGC, n);
  561.     swapl(&stuff->dstGC, n);
  562.     swapl(&stuff->mask, n);
  563.     return((* ProcVector[X_CopyGC])(client));
  564. }
  565.  
  566. int
  567. SProcSetDashes(client)
  568.     register ClientPtr client;
  569. {
  570.     register char n;
  571.     REQUEST(xSetDashesReq);
  572.     swaps(&stuff->length, n);
  573.     swapl(&stuff->gc, n);
  574.     swaps(&stuff->dashOffset, n);
  575.     swaps(&stuff->nDashes, n);
  576.     return((* ProcVector[X_SetDashes])(client));
  577.  
  578. }
  579.  
  580. int
  581. SProcSetClipRectangles(client)
  582.     register ClientPtr client;
  583. {
  584.     register char n;
  585.     REQUEST(xSetClipRectanglesReq);
  586.     swaps(&stuff->length, n);
  587.     swapl(&stuff->gc, n);
  588.     swaps(&stuff->xOrigin, n);
  589.     swaps(&stuff->yOrigin, n);
  590.     SwapRestS(stuff);
  591.     return((* ProcVector[X_SetClipRectangles])(client));
  592. }
  593.  
  594. int
  595. SProcClearToBackground(client)
  596.     register ClientPtr client;
  597. {
  598.     register char n;
  599.     REQUEST(xClearAreaReq);
  600.     swaps(&stuff->length, n);
  601.     swapl(&stuff->window, n);
  602.     swaps(&stuff->x, n);
  603.     swaps(&stuff->y, n);
  604.     swaps(&stuff->width, n);
  605.     swaps(&stuff->height, n);
  606.     return((* ProcVector[X_ClearArea])(client));
  607. }
  608.  
  609. int
  610. SProcCopyArea(client)
  611.     register ClientPtr client;
  612. {
  613.     register char n;
  614.     REQUEST(xCopyAreaReq);
  615.     swaps(&stuff->length, n);
  616.     swapl(&stuff->srcDrawable, n);
  617.     swapl(&stuff->dstDrawable, n);
  618.     swapl(&stuff->gc, n);
  619.     swaps(&stuff->srcX, n);
  620.     swaps(&stuff->srcY, n);
  621.     swaps(&stuff->dstX, n);
  622.     swaps(&stuff->dstY, n);
  623.     swaps(&stuff->width, n);
  624.     swaps(&stuff->height, n);
  625.     return((* ProcVector[X_CopyArea])(client));
  626. }
  627.  
  628. int
  629. SProcCopyPlane(client)
  630.     register ClientPtr client;
  631. {
  632.     register char n;
  633.     REQUEST(xCopyPlaneReq);
  634.     swaps(&stuff->length, n);
  635.     swapl(&stuff->srcDrawable, n);
  636.     swapl(&stuff->dstDrawable, n);
  637.     swapl(&stuff->gc, n);
  638.     swaps(&stuff->srcX, n);
  639.     swaps(&stuff->srcY, n);
  640.     swaps(&stuff->dstX, n);
  641.     swaps(&stuff->dstY, n);
  642.     swaps(&stuff->width, n);
  643.     swaps(&stuff->height, n);
  644.     swapl(&stuff->bitPlane, n);
  645.     return((* ProcVector[X_CopyPlane])(client));
  646. }
  647.  
  648. /* The following routine is used for all Poly drawing requests
  649.    (except FillPoly, which uses a different request format) */
  650. int
  651. SProcPoly(client)
  652.     register ClientPtr client;
  653. {
  654.     register char n;
  655.  
  656.     REQUEST(xPolyPointReq);
  657.     swaps(&stuff->length, n);
  658.     swapl(&stuff->drawable, n);
  659.     swapl(&stuff->gc, n);
  660.     SwapRestS(stuff);
  661.     return((* ProcVector[stuff->reqType])(client));
  662. }
  663.  
  664. /* cannot use SProcPoly for this one, because xFillPolyReq
  665.    is longer than xPolyPointReq, and we don't want to swap
  666.    the difference as shorts! */
  667. int
  668. SProcFillPoly(client)
  669.     register ClientPtr client;
  670. {
  671.     register char n;
  672.  
  673.     REQUEST(xFillPolyReq);
  674.     swaps(&stuff->length, n);
  675.     swapl(&stuff->drawable, n);
  676.     swapl(&stuff->gc, n);
  677.     SwapRestS(stuff);
  678.     return((* ProcVector[X_FillPoly])(client));
  679. }
  680.  
  681. int
  682. SProcPutImage(client)
  683.     register ClientPtr client;
  684. {
  685.     register char n;
  686.     REQUEST(xPutImageReq);
  687.     swaps(&stuff->length, n);
  688.     swapl(&stuff->drawable, n);
  689.     swapl(&stuff->gc, n);
  690.     swaps(&stuff->width, n);
  691.     swaps(&stuff->height, n);
  692.     swaps(&stuff->dstX, n);
  693.     swaps(&stuff->dstY, n);
  694.     /* Image should already be swapped */
  695.     return((* ProcVector[X_PutImage])(client));
  696.  
  697. }
  698.  
  699. int
  700. SProcGetImage(client)
  701.     register ClientPtr    client;
  702. {
  703.     register char n;
  704.     REQUEST(xGetImageReq);
  705.     swaps(&stuff->length, n);
  706.     swapl(&stuff->drawable, n);
  707.     swaps(&stuff->x, n);
  708.     swaps(&stuff->y, n);
  709.     swaps(&stuff->width, n);
  710.     swaps(&stuff->height, n);
  711.     swapl(&stuff->planeMask, n);
  712.     return((* ProcVector[X_GetImage])(client));
  713. }
  714.  
  715. /* ProcPolyText used for both PolyText8 and PolyText16 */
  716.  
  717. int
  718. SProcPolyText(client)
  719.     register ClientPtr client;
  720. {
  721.     register char n;
  722.     REQUEST(xPolyTextReq);
  723.     swaps(&stuff->length, n);
  724.     swapl(&stuff->drawable, n);
  725.     swapl(&stuff->gc, n);
  726.     swaps(&stuff->x, n);
  727.     swaps(&stuff->y, n);
  728.     return((* ProcVector[stuff->reqType])(client));
  729. }
  730.  
  731. /* ProcImageText used for both ImageText8 and ImageText16 */
  732.  
  733. int
  734. SProcImageText(client)
  735.     register ClientPtr client;
  736. {
  737.     register char n;
  738.     REQUEST(xImageTextReq);
  739.     swaps(&stuff->length, n);
  740.     swapl(&stuff->drawable, n);
  741.     swapl(&stuff->gc, n);
  742.     swaps(&stuff->x, n);
  743.     swaps(&stuff->y, n);
  744.     return((* ProcVector[stuff->reqType])(client));
  745. }
  746.  
  747. int
  748. SProcCreateColormap(client)
  749.     register ClientPtr client;
  750. {
  751.     register char n;
  752.     REQUEST(xCreateColormapReq);
  753.     swaps(&stuff->length, n);
  754.     swapl(&stuff->mid, n);
  755.     swapl(&stuff->window, n);
  756.     swapl(&stuff->visual, n);
  757.     return((* ProcVector[X_CreateColormap])(client));
  758. }
  759.  
  760.  
  761. int
  762. SProcCopyColormapAndFree(client)
  763.     register ClientPtr client;
  764. {
  765.     register char n;
  766.     REQUEST(xCopyColormapAndFreeReq);
  767.     swaps(&stuff->length, n);
  768.     swapl(&stuff->mid, n);
  769.     swapl(&stuff->srcCmap, n);
  770.     return((* ProcVector[X_CopyColormapAndFree])(client));
  771.  
  772. }
  773.  
  774. int
  775. SProcAllocColor                (client)
  776.     register ClientPtr client;
  777. {
  778.     register char n;
  779.     REQUEST(xAllocColorReq);
  780.     swaps(&stuff->length, n);
  781.     swapl(&stuff->cmap, n);
  782.     swaps(&stuff->red, n);
  783.     swaps(&stuff->green, n);
  784.     swaps(&stuff->blue, n);
  785.     return((* ProcVector[X_AllocColor])(client));
  786. }
  787.  
  788. int
  789. SProcAllocNamedColor           (client)
  790.     register ClientPtr client;
  791. {
  792.     register char n;
  793.  
  794.     REQUEST(xAllocNamedColorReq);
  795.     swaps(&stuff->length, n);
  796.     swapl(&stuff->cmap, n);
  797.     swaps(&stuff->nbytes, n);
  798.     return((* ProcVector[X_AllocNamedColor])(client));
  799. }
  800.  
  801. int
  802. SProcAllocColorCells           (client)
  803.     register ClientPtr client;
  804. {
  805.     register char n;
  806.     REQUEST(xAllocColorCellsReq);
  807.     swaps(&stuff->length, n);
  808.     swapl(&stuff->cmap, n);
  809.     swaps(&stuff->colors, n);
  810.     swaps(&stuff->planes, n);
  811.     return((* ProcVector[X_AllocColorCells])(client));
  812. }
  813.  
  814. int
  815. SProcAllocColorPlanes(client)
  816.     register ClientPtr client;
  817. {
  818.     register char n;
  819.     REQUEST(xAllocColorPlanesReq);
  820.     swaps(&stuff->length, n);
  821.     swapl(&stuff->cmap, n);
  822.     swaps(&stuff->colors, n);
  823.     swaps(&stuff->red, n);
  824.     swaps(&stuff->green, n);
  825.     swaps(&stuff->blue, n);
  826.     return((* ProcVector[X_AllocColorPlanes])(client));
  827. }
  828.  
  829. int
  830. SProcFreeColors          (client)
  831.     register ClientPtr client;
  832. {
  833.     register char n;
  834.     REQUEST(xFreeColorsReq);
  835.     swaps(&stuff->length, n);
  836.     REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
  837.     swapl(&stuff->cmap, n);
  838.     swapl(&stuff->planeMask, n);
  839.     SwapRestL(stuff);
  840.     return((* ProcVector[X_FreeColors])(client));
  841.  
  842. }
  843.  
  844. int
  845. SProcStoreColors               (client)
  846.     register ClientPtr client;
  847. {
  848.     register char n;
  849.     unsigned long count;
  850.     xColorItem     *pItem;
  851.  
  852.     REQUEST(xStoreColorsReq);
  853.     swaps(&stuff->length, n);
  854.     swapl(&stuff->cmap, n);
  855.     pItem = (xColorItem *) &stuff[1];
  856.     for(count = LengthRestB(stuff)/sizeof(xColorItem); count != 0; count--)
  857.     SwapColorItem(pItem++);
  858.     return((* ProcVector[X_StoreColors])(client));
  859. }
  860.  
  861. int
  862. SProcStoreNamedColor           (client)
  863.     register ClientPtr client;
  864. {
  865.     register char n;
  866.     REQUEST(xStoreNamedColorReq);
  867.     swaps(&stuff->length, n);
  868.     swapl(&stuff->cmap, n);
  869.     swapl(&stuff->pixel, n);
  870.     swaps(&stuff->nbytes, n);
  871.     return((* ProcVector[X_StoreNamedColor])(client));
  872. }
  873.  
  874. int
  875. SProcQueryColors(client)
  876.     register ClientPtr client;
  877. {
  878.     register char n;
  879.     REQUEST(xQueryColorsReq);
  880.     swaps(&stuff->length, n);
  881.     REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
  882.     swapl(&stuff->cmap, n);
  883.     SwapRestL(stuff);
  884.     return((* ProcVector[X_QueryColors])(client));
  885.  
  886. int
  887. SProcLookupColor(client)
  888.     register ClientPtr client;
  889. {
  890.     register char n;
  891.     REQUEST(xLookupColorReq);
  892.     swaps(&stuff->length, n);
  893.     swapl(&stuff->cmap, n);
  894.     swaps(&stuff->nbytes, n);
  895.     return((* ProcVector[X_LookupColor])(client));
  896. }
  897.  
  898. int
  899. SProcCreateCursor( client)
  900.     register ClientPtr client;
  901. {
  902.     register char n;
  903.     REQUEST(xCreateCursorReq);
  904.     swaps(&stuff->length, n);
  905.     swapl(&stuff->cid, n);
  906.     swapl(&stuff->source, n);
  907.     swapl(&stuff->mask, n);
  908.     swaps(&stuff->foreRed, n);
  909.     swaps(&stuff->foreGreen, n);
  910.     swaps(&stuff->foreBlue, n);
  911.     swaps(&stuff->backRed, n);
  912.     swaps(&stuff->backGreen, n);
  913.     swaps(&stuff->backBlue, n);
  914.     swaps(&stuff->x, n);
  915.     swaps(&stuff->y, n);
  916.     return((* ProcVector[X_CreateCursor])(client));
  917. }
  918.  
  919. int
  920. SProcCreateGlyphCursor( client)
  921.     register ClientPtr client;
  922. {
  923.     register char n;
  924.     REQUEST(xCreateGlyphCursorReq);
  925.     swaps(&stuff->length, n);
  926.     swapl(&stuff->cid, n);
  927.     swapl(&stuff->source, n);
  928.     swapl(&stuff->mask, n);
  929.     swaps(&stuff->sourceChar, n);
  930.     swaps(&stuff->maskChar, n);
  931.     swaps(&stuff->foreRed, n);
  932.     swaps(&stuff->foreGreen, n);
  933.     swaps(&stuff->foreBlue, n);
  934.     swaps(&stuff->backRed, n);
  935.     swaps(&stuff->backGreen, n);
  936.     swaps(&stuff->backBlue, n);
  937.     return((* ProcVector[X_CreateGlyphCursor])(client));
  938. }
  939.  
  940.  
  941. int
  942. SProcRecolorCursor(client)
  943.     register ClientPtr client;
  944. {
  945.     register char n;
  946.     REQUEST(xRecolorCursorReq);
  947.     swaps(&stuff->length, n);
  948.     swapl(&stuff->cursor, n);
  949.     swaps(&stuff->foreRed, n);
  950.     swaps(&stuff->foreGreen, n);
  951.     swaps(&stuff->foreBlue, n);
  952.     swaps(&stuff->backRed, n);
  953.     swaps(&stuff->backGreen, n);
  954.     swaps(&stuff->backBlue, n);
  955.     return((* ProcVector[X_RecolorCursor])(client));
  956. }
  957.  
  958. int
  959. SProcQueryBestSize   (client)
  960.     register ClientPtr client;
  961. {
  962.     register char n;
  963.     REQUEST(xQueryBestSizeReq);
  964.     swaps(&stuff->length, n);
  965.     swapl(&stuff->drawable, n);
  966.     swaps(&stuff->width, n);
  967.     swaps(&stuff->height, n);
  968.     return((* ProcVector[X_QueryBestSize])(client));
  969.  
  970. }
  971.  
  972. int
  973. SProcQueryExtension   (client)
  974.     register ClientPtr client;
  975. {
  976.     register char n;
  977.     REQUEST(xQueryExtensionReq);
  978.     swaps(&stuff->length, n);
  979.     swaps(&stuff->nbytes, n);
  980.     return((* ProcVector[X_QueryExtension])(client));
  981. }
  982.  
  983. int
  984. SProcChangeKeyboardMapping   (client)
  985.     register ClientPtr client;
  986. {
  987.     register char n;
  988.     register long *p;
  989.     register int i, count;
  990.  
  991.     REQUEST(xChangeKeyboardMappingReq);
  992.     swaps(&stuff->length, n);
  993.     p = (long *)&stuff[1];
  994.     count = stuff->keyCodes * stuff->keySymsPerKeyCode;
  995.     for(i = 0; i < count; i++)
  996.     {
  997.         swapl(p, n);
  998.     p++;
  999.     }
  1000.     return((* ProcVector[X_ChangeKeyboardMapping])(client));
  1001. }
  1002.  
  1003.  
  1004. int
  1005. SProcChangeKeyboardControl   (client)
  1006.     register ClientPtr client;
  1007. {
  1008.     register char n;
  1009.     REQUEST(xChangeKeyboardControlReq);
  1010.     swaps(&stuff->length, n);
  1011.     REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
  1012.     swapl(&stuff->mask, n);
  1013.     SwapRestL(stuff);
  1014.     return((* ProcVector[X_ChangeKeyboardControl])(client));
  1015. }
  1016.  
  1017. int
  1018. SProcChangePointerControl   (client)
  1019.     register ClientPtr client;
  1020. {
  1021.     register char n;
  1022.     REQUEST(xChangePointerControlReq);
  1023.     swaps(&stuff->length, n);
  1024.     swaps(&stuff->accelNum, n);
  1025.     swaps(&stuff->accelDenum, n);
  1026.     swaps(&stuff->threshold, n);
  1027.     return((* ProcVector[X_ChangePointerControl])(client));
  1028. }
  1029.  
  1030.  
  1031. int
  1032. SProcSetScreenSaver            (client)
  1033.     register ClientPtr client;
  1034. {
  1035.     register char n;
  1036.     REQUEST(xSetScreenSaverReq);
  1037.     swaps(&stuff->length, n);
  1038.     swaps(&stuff->timeout, n);
  1039.     swaps(&stuff->interval, n);
  1040.     return((* ProcVector[X_SetScreenSaver])(client));
  1041. }
  1042.  
  1043. int
  1044. SProcChangeHosts(client)
  1045.     register ClientPtr client;
  1046. {
  1047.     register char n;
  1048.  
  1049.     REQUEST(xChangeHostsReq);
  1050.     swaps(&stuff->length, n);
  1051.     swaps(&stuff->hostLength, n);
  1052.     return((* ProcVector[X_ChangeHosts])(client));
  1053.  
  1054. }
  1055.  
  1056. int SProcRotateProperties(client)
  1057.     register ClientPtr client;
  1058. {
  1059.     register char n;
  1060.     REQUEST(xRotatePropertiesReq);
  1061.     swaps(&stuff->length, n);
  1062.     swapl(&stuff->window, n);
  1063.     swaps(&stuff->nAtoms, n);
  1064.     REQUEST_FIXED_SIZE(xRotatePropertiesReq, stuff->nAtoms << 2);
  1065.     swaps(&stuff->nPositions, n);
  1066.     SwapRestL(stuff);
  1067.     return ((* ProcVector[X_RotateProperties])(client));
  1068. }
  1069.  
  1070. /*ARGSUSED*/
  1071. int
  1072. SProcNoOperation(client)
  1073.     ClientPtr client;
  1074. {
  1075.     /* noop -- don't do anything */
  1076.     return(Success);
  1077. }
  1078.  
  1079. SwapTimecoord(pCoord)
  1080.     xTimecoord *pCoord;
  1081. {
  1082.     register char n;
  1083.  
  1084.     swapl(&pCoord->time, n);
  1085.     swaps(&pCoord->x, n);
  1086.     swaps(&pCoord->y, n);
  1087. }
  1088.  
  1089.  
  1090. SwapRGB(prgb)
  1091.     xrgb    *prgb;
  1092. {
  1093.     register char n;
  1094.  
  1095.     swaps(&prgb->red, n);
  1096.     swaps(&prgb->green, n);
  1097.     swaps(&prgb->blue, n);
  1098. }
  1099.  
  1100. SwapColorItem(pItem)
  1101.     xColorItem    *pItem;
  1102. {
  1103.     register char n;
  1104.  
  1105.     swapl(&pItem->pixel, n);
  1106.     swaps(&pItem->red, n);
  1107.     swaps(&pItem->green, n);
  1108.     swaps(&pItem->blue, n);
  1109. }
  1110.  
  1111. SwapConnClientPrefix(pCCP)
  1112.     xConnClientPrefix    *pCCP;
  1113. {
  1114.     register char n;
  1115.  
  1116.     swaps(&pCCP->majorVersion, n);
  1117.     swaps(&pCCP->minorVersion, n);
  1118.     swaps(&pCCP->nbytesAuthProto, n);
  1119.     swaps(&pCCP->nbytesAuthString, n);
  1120. }
  1121.  
  1122.